package com.ruoyi.work.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.Pages;
import com.ruoyi.common.core.page.Query;
import com.ruoyi.common.query.QueryTool;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkBillDetailMapper;
import com.ruoyi.work.domain.WorkBillDetail;
import com.ruoyi.work.service.IWorkBillDetailService;

/**
 * 工单详情Service业务层处理
 * 
 * @author xwj
 * @date 2024-08-19
 */
@Service
public class WorkBillDetailServiceImpl extends ServiceImpl<WorkBillDetailMapper, WorkBillDetail> implements IWorkBillDetailService {
    @Autowired
    private WorkBillDetailMapper workBillDetailMapper;

    /**
     * 查询工单详情
     * 
     * @param id 工单详情主键
     * @return 工单详情
     */
    @Override
    public WorkBillDetail selectWorkBillDetailById(Long id) {
        return workBillDetailMapper.selectWorkBillDetailById(id);
    }

    /**
     * 查询工单详情列表
     * 
     * @param workBillDetail 工单详情
     * @return 工单详情
     */
    @Override
    public List<WorkBillDetail> selectWorkBillDetailList(WorkBillDetail workBillDetail) {
        return workBillDetailMapper.selectWorkBillDetailList(workBillDetail);
    }

    /**
     * 新增工单详情
     * 
     * @param workBillDetail 工单详情
     * @return 结果
     */
    @Override
    public WorkBillDetail insertWorkBillDetail(WorkBillDetail workBillDetail) {

      //  workBillDetailMapper.insertWorkBillDetail(workBillDetail);
    save(workBillDetail);
    return workBillDetail;
    }

    /**
     * 修改工单详情
     * 
     * @param workBillDetail 工单详情
     * @return 结果
     */
    @Override
    public WorkBillDetail updateWorkBillDetail(WorkBillDetail workBillDetail) {

      //  workBillDetailMapper.updateWorkBillDetail(workBillDetail);
        updateById(workBillDetail);
        return workBillDetail;
    }

    /**
     * 批量删除工单详情
     * 
     * @param ids 需要删除的工单详情主键
     * @return 结果
     */
    @Override
    public int deleteWorkBillDetailByIds(Long[] ids) {
        return workBillDetailMapper.deleteWorkBillDetailByIds(ids);
    }

    /**
    * 条件删除
    * @param workBillDetail 工单详情
    * @return
    */
    @Override
    public int delete(WorkBillDetail workBillDetail) {
        QueryWrapper<WorkBillDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, workBillDetail);
        return baseMapper.delete(qw);
    }

    /**
     * mp分页
     * @param workBillDetail 工单详情
     * @return
     */
    @Override
    public Pages<WorkBillDetail> queryPage(WorkBillDetail workBillDetail) {
        QueryWrapper<WorkBillDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, workBillDetail);
        IPage<WorkBillDetail> ipage = new Query<WorkBillDetail>().getPage(workBillDetail);

        IPage<WorkBillDetail> page = this.page(
                ipage,
                qw
        );
        return new Pages<>(page);
    }

    @Override
    public void deleteWorkBillDetailByBillIds(Long[] ids) {
        workBillDetailMapper.deleteWorkBillDetailByBillIds(ids);
    }

    /**
     * 删除工单详情信息
     * 
     * @param id 工单详情主键
     * @return 结果
     */
    @Override
    public int deleteWorkBillDetailById(Long id) {
        return workBillDetailMapper.deleteWorkBillDetailById(id);
    }
}
